#include <iostream>

using namespace std;
int n,na,nb;
int a[205],b[205];
int r[5][5]={
	{0,0,1,1,0},
	{1,0,0,1,0},
	{0,1,0,0,1},
	{0,0,1,0,1},
	{1,1,0,0,0}
};

int main(){
	int sa=0,sb=0;
	cin>>n>>na>>nb;
	for(int i=0;i<na;i++){
		cin>>a[i];
	}
	for(int i=0;i<nb;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		sa+=r[a[i%na]][b[i%nb]];
		sb+=r[b[i%nb]][a[i%na]];
	}
	cout<<sa<<" "<<sb;
	return 0;
}
